package apps.softtech.Model;

import android.content.ContentValues;
import android.database.Cursor;

public class Comment {

	public static final String TABLE_NAME = "Comment";

	public static final String COMMENT_ID = "commentId";

	private int commentId;

	public static final String COMMENT_CONTENT = "st_CommentContent";
	private String commentContent;

	public static final String CREATED_DATE = "st_CreatetDate";
	private String createdDate;

	public static final String PRODUCT_ID = "st_ProductId";
	private int productId;

	public static final String USERID = "st_UserId";
	private int userId;

	public Comment() {
		super();
	}

	public Comment(int commentId, String commentContent, String createdDate,
			int productId, int userId) {
		super();
		this.commentId = commentId;
		this.commentContent = commentContent;
		this.createdDate = createdDate;
		this.productId = productId;
		this.userId = userId;
	}

	public Comment(String commentContent, String createdDate, int productId,
			int userId) {
		super();
		this.commentContent = commentContent;
		this.createdDate = createdDate;
		this.productId = productId;
		this.userId = userId;
	}

	public int getCommentId() {
		return commentId;
	}

	public void setCommentId(int commentId) {
		this.commentId = commentId;
	}

	public String getCommentContent() {
		return commentContent;
	}

	public void setCommentContent(String commentContent) {
		this.commentContent = commentContent;
	}

	public String getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(String createdDate) {
		this.createdDate = createdDate;
	}

	public int getProductId() {
		return productId;
	}

	public void setProductId(int productId) {
		this.productId = productId;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	/**
	 * get values from Comment
	 * @author MUI
	 * @return contentvalues
	 */
	public ContentValues getValuesComment() {
		ContentValues values = new ContentValues();
		values.put(COMMENT_CONTENT, this.getCommentContent());
		values.put(CREATED_DATE, this.getCreatedDate());
		values.put(PRODUCT_ID, this.getProductId());
		values.put(USERID, this.getUserId());

		return values;

	}

	public void setValueFromCursor(Cursor c) {
		
		if(c.getColumnIndex(Comment.COMMENT_ID)>=0){
			setCommentId(c.getInt(c.getColumnIndex(COMMENT_ID)));
		}
		if(c.getColumnIndex(PRODUCT_ID)>=0){
			setProductId(c.getInt(c.getColumnIndex(PRODUCT_ID)));
		}
		if(c.getColumnIndex(USERID)>=0){
			setUserId(c.getInt(c.getColumnIndex(USERID)));
		}
		if(c.getColumnIndex(COMMENT_CONTENT)>=0){
			setCommentContent(c.getString(c.getColumnIndex(COMMENT_CONTENT)));
		}
		if(c.getColumnIndex(CREATED_DATE)>=0){
			setCreatedDate(c.getString(c.getColumnIndex(CREATED_DATE)));
		}
	}
}
